home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / programming / mui / mcc_popph / mcc_popph_src / popph_demo.c < prev    next >
C/C++ Source or Header  |  1999-11-30  |  6KB  |  207 lines

  1.  
  2. /*
  3. ** $Id: popph_demo.c,v 1.2 1999/11/16 20:58:11 carlos Exp $
  4. **
  5. ** Popplaceholder.mcc - demonstration program
  6. ** © 1999 Marcin Orlowski <carlos@amiga.com.pl>
  7. **                        http://amiga.com.pl/mcc/
  8. */
  9.  
  10. /// Includes
  11.  
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include <ctype.h>
  15. #include <stdlib.h>
  16. #include <exec/types.h>
  17. #include <libraries/mui.h>
  18. #include <libraries/asl.h>
  19. #include <proto/exec.h>
  20. #include <proto/muimaster.h>
  21.  
  22. #include "Popplaceholder_mcc.h"
  23.  
  24. LONG __stack = 18192;
  25.  
  26. #define SAVEDS __saveds
  27. #define ASM __asm
  28. #define REG(x) register __ ## x
  29.  
  30. //|
  31.  
  32. char VER[] = "$VER: PopplaceholderDemo 15.0 (23.11.99)";
  33.  
  34. /// CleanUp
  35. void CleanUp(void)
  36. {
  37.    if(MUIMasterBase)   {CloseLibrary(MUIMasterBase); MUIMasterBase = NULL; }
  38. }
  39. //|
  40. /// xget
  41. ULONG xget( Object *obj, int attr)
  42. {
  43. ULONG val;
  44.  
  45.         get( obj, attr, &val);
  46.         return( val );
  47. }
  48. //|
  49.  
  50. /// Main
  51.  
  52. static const char *PP_Table[] =
  53. {
  54.     "%s|normal",
  55.     "%g|highlight",
  56.     "%x|3-dimensional",
  57.     "%w|4-dimensional",
  58.     "Tag|Description",
  59.     "WWW|World Wide Web",
  60.     NULL
  61. };
  62.  
  63. static const char *PP_Table_Single[] =
  64. {
  65.         "something 1",
  66.         "something 2",
  67.         "something 3",
  68.         NULL
  69. };
  70.  
  71. struct  Library *MUIMasterBase  = NULL;
  72.  
  73. #define TextObj(a) TextObject, MUIA_Text_Contents, (a), MUIA_Font, MUIV_Font_Tiny, End
  74.  
  75.  
  76. int main(void)
  77. {
  78.  
  79. APTR app, window, pph;
  80.  
  81.  
  82.    if( !(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN)) )
  83.        {
  84.        printf("Can't open %s v%ld\n", MUIMASTER_NAME, MUIMASTER_VMIN);
  85.        CleanUp();
  86.        return(EXIT_FAILURE);
  87.        }
  88.  
  89.    app = ApplicationObject,
  90.             MUIA_Application_Title      , "Popplaceholder Demo",
  91. //            MUIA_Application_Version    , VERSTAG,
  92.             MUIA_Application_Copyright  , "©1999 Marcin Orlowski <carlos@amiga.com.pl>",
  93.             MUIA_Application_Author     , "Marcin Orlowski",
  94.             MUIA_Application_Base       , "POPPLACEHOLDERDEMO",
  95.             MUIA_Application_Window     ,
  96.                window = WindowObject,
  97.                         MUIA_Window_ID, 0,
  98.                         MUIA_Window_Title, "Popplaceholder demo",
  99.                         WindowContents,
  100.                               VGroup,
  101.                               Child, TextObj("\033cOrdinary object"),
  102.                               Child, pph = PopphObject,
  103.                                      MUIA_Popph_Array      , PP_Table,
  104.                                      MUIA_Popph_Contents   , "Something",
  105. //                                     MUIA_Popph_ReplaceMode, TRUE,
  106.                                      End,
  107.  
  108.  
  109.                               Child, TextObj("\033cAnd PopAsl alike"),
  110.                               Child, PopphObject,
  111.                                      MUIA_Popph_Contents   , "300 chars limit",
  112.                                      MUIA_Popph_Array      , PP_Table,
  113.                                      MUIA_Popph_PopAsl     , TRUE,
  114.                                      MUIA_Popph_Contents   , "RAM:",
  115.                                      ASLFR_DoSaveMode      , TRUE,
  116.                                      End,
  117.  
  118.  
  119.                               Child, TextObj("\033cAnother PopAsl (drawers only)"),
  120.                               Child, PopphObject,
  121.                                      MUIA_Popph_Array      , PP_Table,
  122.                                      MUIA_Popph_PopAsl     , TRUE,
  123.                                      MUIA_Popph_Contents   , "SYS:",
  124.                                      ASLFR_DrawersOnly     , TRUE,
  125.                                      End,
  126.  
  127.  
  128.                               Child, TextObj("\033cAlways 'classic' string (we Avoid others)"),
  129.                               Child, PopphObject,
  130.                                      MUIA_Popph_Array      , PP_Table,
  131.                                      MUIA_Popph_Avoid      , MUIV_Popph_Avoid_Textinput | MUIV_Popph_Avoid_Betterstring,
  132.                                      End,
  133.  
  134. /*
  135.                               // not implemented yet!
  136.                               Child, TextObject, MUIA_Text_Contents, "\033cLet's override the string object", End,
  137.                               Child, PopphObject,
  138.                                      MUIA_Popph_Array       , PP_Table,
  139.                                      MUIA_Popph_StringObject, StringObject, End,
  140.                                      End,
  141. */
  142.  
  143.                               Child, TextObj("\033cList with column title"),
  144.                               Child, PopphObject,
  145.                                      MUIA_Popph_Array      , PP_Table,
  146.                                      MUIA_Popph_Title      , "\033bCol1|\033u\033iCol2",
  147.                                      MUIA_Popph_Contents   , "Nothing ;-)",
  148.                                      End,
  149.  
  150.                               Child, TextObj("\033cSingle column..."),
  151.                               Child, PopphObject,
  152.                                      MUIA_Popph_Array       , PP_Table_Single,
  153.                                                             MUIA_Popph_SingleColumn, TRUE,
  154.                                      MUIA_Popph_Title       , "\033bTitle",
  155.                                      MUIA_Popph_Contents    , "... with replace mode on",
  156.                                      MUIA_Popph_ReplaceMode , TRUE,
  157.                                      End,
  158.  
  159.  
  160.  
  161.                               End,
  162.                         End,
  163.  
  164.                  End;
  165.  
  166.  
  167.  
  168.       if(app)
  169.         {
  170.         DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  171.  
  172.  
  173.         set(window,MUIA_Window_Open,TRUE);
  174.  
  175.         if( xget(window, MUIA_Window_Open) )
  176.            {
  177.            ULONG sigs = 0;
  178.  
  179.            while(DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  180.              {
  181.              if(sigs)
  182.                {
  183.                sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  184.                if(sigs & SIGBREAKF_CTRL_C) break;
  185.                }
  186.              }
  187.            }
  188.         else
  189.            {
  190.            printf("Can't open window!\n");
  191.            }
  192.  
  193. //              printf( "Result string: '%s'\n", xget(pph, MUIA_Popph_Contents) );
  194.  
  195.         MUI_DisposeObject(app);
  196.         }
  197.       else
  198.         {
  199.         printf("Can't create application object\n");
  200.         DisplayBeep(NULL);
  201.         }
  202.  
  203.    CleanUp();
  204.    return(EXIT_SUCCESS);
  205. }
  206. //|
  207.